package com.hbt.orderfood.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBOpenHelper extends SQLiteOpenHelper {


    public DBOpenHelper(@Nullable Context context) {
        super(context, "database.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String user_sql = "create table "+UserTable.TABLE_NAME+" ("
                +" _id integer primary key autoincrement, "
                +UserTable.USERNAME+" TEXT, "
                +UserTable.PASSWORD+" TEXT"
                +")";
        String food_sql = "create table "+FoodTable.TABLE_NAME+" ("
                +" _id integer primary key autoincrement, "
                +FoodTable.NAME+" TEXT, "
                +FoodTable.TYPE+" TEXT, "
                +FoodTable.PRICE+" integer"
                +")";
        String order_sql = "create table "+OrderTable.TABLE_NAME+" ("
                +" _id integer primary key autoincrement, "
                +OrderTable.FOOD_ID+" integer, "
                +OrderTable.USER_ID+" integer, "
                +OrderTable.NUM+" integer,"
                +OrderTable.PRICE+" integer"
                +")";
        db.execSQL(user_sql);
        db.execSQL(food_sql);
        db.execSQL(order_sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
